<?php

include_once($cfgPaths['lib'].'cms/type/cmsEditType.o.inc.php');

/**
 * Class SimpleViewerEditType
 *
 * @author Marcel Linnenfelser
 * @package
 * @since 26.08.2009
 * @license XICS License
 */
class SimpleViewerEditType extends cmsEditType {

 function registerFields () {
   $map[] = $this->name.'title';
   $map[] = $this->name.'gallery';
   $this->map = &$map;
 }

 function render_html () {
    global $cfgPaths,$cfgDeveloperMode,$env;
    $galleryname = $this->getValue($this->name.'gallery');
    $html  = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'."\n";
    $html .= '  <tr>'."\n";
    $html .= '    <td bgcolor="#000000">'."\n";
    $html .= '      <table border="0" cellspacing="1" cellpadding="3" width="100%">'."\n";
    $html .= '        <tr>'."\n";
    $html .= '          <td width="100" bgcolor="#E0F6FD" valign="top">'."\n";
    $html .= '              <b>'.$this->descr.':</b>'.$this->showFields().'</td>'."\n";
    $html .= '          <td bgcolor="#E0F6FD">'."\n";
    $html .= '  <table border="0">'."\n";
    $html .= '     <tr>'."\n";
    $html .= '      <td>Titel:</td>'."\n";
    $html .= '      <td>'."\n";
    $html .= '        <input tabindex="'.$this->sender->getNextTabindex($this->name.'title').'" name="'.$this->name.'title" value="'.htmlspecialchars($this->getValue($this->name.'title')).'" size="50" maxlength="255"><td>'."\n";
    $html .= '     </tr>'."\n";
    $html .= '     <tr>'."\n";
    $html .= '      <td>Galerie:</td>'."\n";
    $html .= '      <td>'."\n";
    $html .= '<select name="'.$this->name.'gallery" tabindex="'.$this->sender->getNextTabindex($this->name.'gallery').'">'."\n";
    $dir = $cfgPaths['simpleViewer']['path'];
    if (file_exists($dir)){
        $dh = opendir($dir);
        rewinddir($dh);
        while($file = readdir($dh))
        {
            if ($file[0] != '.' && is_dir($dir.$file)){
                $html .= '<option';
                if ($file==$galleryname)
                    $html .= " selected";
                $html .= '>'.$file.'</option>';
            }
        }
        closedir($dh);
    }
    $html .= '</select></td>'."\n";
    $html .= '     </tr>'."\n";
    $html .= '  </table>'."\n";
    $html .= '        </td></tr>'."\n";
    $html .= '      </table></td>'."\n";
    $html .= '  </tr>'."\n";
    $html .= '</table><br>'."\n";
    return $html;
 }

 function render_javascript () {
 }

}


?>